package com.monolithiot.sso.common.util;

import com.monolithiot.sso.common.data.Terminable;

import java.util.Date;

/**
 * 2018/12/14 Create by 郭文梁
 * AuthorizationUtil
 * 授权工具类
 *
 * @author 郭文梁
 * @date 2018/12/14
 */
public class AuthorizationUtil {
    /**
     * 判断授权受否过期
     *
     * @param terminable 授权对象
     * @return 是否过期
     */
    public static boolean isOverdue(Terminable terminable) {
        long now = System.currentTimeMillis();
        Date lastActivityTime = terminable.getLastActivityTime();
        long idleTime = (now - lastActivityTime.getTime()) / 1000;
        return idleTime > terminable.getExpireIn();
    }
}

